/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.unioeste.cc.vm;


/**
 *
 * @author diego
 */
public class VirtualMachine {

    public void execute() {
        Adder adder = new Adder();
        Alu alu = new Alu();
        AluControl aluControl = new AluControl();
        //MemoryInstruction memoryInstruction = new MemoryInstruction();
        Mux muxRegister = new Mux();
        Mux muxAlu = new Mux();
        Mux muxData = new Mux();
        Mux muxJump= new Mux();
        
        Pc pc = new Pc();
        Registers registers = new Registers();
        UnitControl unitControl = new UnitControl();


//        for (int i = 0; i < memoryInstruction.getMemoryRead().size(); i++) {
//
//            memoryInstruction.searchInstruction();
//            System.out.println("Busca Instrução: " + memoryInstruction.getInst());
//
//            pc.incPc();
//            System.out.println("PC + 4 = " + pc.getAdress());
//            memoryInstruction.setPc(pc.getAdress());
//            memoryInstruction.instructionType();
//
//            unitControl.setOpCode(memoryInstruction.getOpcode());
//            unitControl.signalControl();
//
//            muxRegister.setSignal(unitControl.getRegDst());
//            System.out.println("\n" + "Signal MuxResgiter = " + muxRegister.getSignal());
//            muxRegister.setInput0(memoryInstruction.getRt());
//            System.out.println("Input0 MuxResgiter = " + muxRegister.getInput0());
//            muxRegister.setInput1(memoryInstruction.getRd());
//            System.out.println("Input1 MuxResgiter = " + muxRegister.getInput1());
//            muxRegister.selectOutput();
//            System.out.println("Output MuxRegister = " + muxRegister.getOutput() + "\n");
//
//            registers.createContents();
//            registers.setReadReg1(memoryInstruction.getRs());
//            System.out.println("readRegister1 = " + registers.getReadReg1());
//            registers.setReadReg2(memoryInstruction.getRt());
//            System.out.println("readRegister2 = " + registers.getReadReg2());
//            registers.setWriteReg(muxRegister.getOutput());
//            System.out.println("Write Reg = " + registers.getWriteReg());
//            //registers.setReadData1(5);
//            registers.getContents().add(8,5);
//            registers.getContents().add(9,3);
//            System.out.println(registers.getContents());
//            
//            
//            
//            registers.setReadData1(registers.getContents().get(registers.getReadReg1()));
//            System.out.println("ReadData1 = " + registers.getReadData1());
//            //registers.setReadData2(3);
//            registers.setReadData2(registers.getContents().get(registers.getReadReg2()));
//
//            System.out.println("ReadData2 = " + registers.getReadData2() + "\n");
//
//            aluControl.setAluOp(unitControl.getAluOp());
//            System.out.println("Aluop = " + aluControl.getAluOp());
//            aluControl.setFunct(memoryInstruction.getFunct());
//            System.out.println("Funct = " + aluControl.getFunct());
//            aluControl.generateOutput();
//            System.out.println("Output = " + aluControl.getOutput() + "\n");
//
//            muxAlu.setSignal(unitControl.getAluSrc());
//            System.out.println("AluSrc = " + muxAlu.getSignal() + "\n");
//            muxAlu.setInput0(registers.getReadData2());
//            //muxAlu.setInput1([15-0]); //nao utilizado ainda... somente ira utilizar se for uma LW ou SW
//            muxAlu.selectOutput();
//
//
//            alu.setOp1(registers.getReadData1());
//            System.out.println("Op1 = " + alu.getOp1());
//            alu.setOp2(muxAlu.getOutput());
//            System.out.println("Op2 = " + alu.getOp2());
//            alu.setSignalAluControl(aluControl.getOutput());
//            alu.execute();
//            System.out.println("Result = " + alu.getResult());
//
//            registers.setWriteData(alu.getResult());
//            System.out.println("WriteData = " + registers.getWriteData() + "\n");
//            System.out.println("--------------------------------------------------------------------------------------------------");
//

//        }
    }
}
